import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export const constantRouterMap = [
    {
        path: '/',
        name: 'Index',
        component: () => import('@/views/Index'),
        children: []
    },
    {
        path: '/hotel',
        name: 'Hotel',
        component: () => import('@/views/Hotel')
    }, {
        path: '/order',
        name: 'Order',
        component: () => import('@/views/HotelOrder')
    }, {
        path: '/score',
        name: 'Score',
        component: () => import('@/views/Score')
    },,{
        path: '/login',
        name: 'Login',
        component: () => import('@/views/admin/Login'),
    }, {
        path: '/admin',
        name: 'Admin',
        meta: {
            requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
        },
        component: () => import('@/views/admin/Admin'),
        children: [
            {
                path : '/user',
                name : 'User',
                meta: {
                    requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
                },
                component : ()=> import('@/views/admin/User')
            }, {
                path : '/role',
                name : 'Role',
                meta: {
                    requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
                },
                component : ()=> import('@/views/admin/Role')
            }, {
                path : '/room',
                name : 'Room',
                meta: {
                    requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
                },
                component : ()=> import('@/views/admin/Room')
            }, {
                path : '/roomtype',
                name : 'RoomType',
                meta: {
                    requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
                },
                component : ()=> import('@/views/admin/RoomType')
            }, {
                path : '/orders',
                name : 'Orders',
                meta: {
                    requireAuth: true,  // 添加该字段，表示进入这个路由是需要登录的
                },
                component : ()=> import('@/views/admin/Orders')
            },
        ],
    }
]

const router = new Router({
    mode:'history',
    routes: constantRouterMap
})

export default router
